26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
50 #pragma package(smart_init)
63 Graphics::TBitmap* SmallGraphicPtrVal): SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
65 for(
int x = 0; x < 4; x++)
74 else if(SpeedTagVal == 77)
76 else if(SpeedTagVal == 78)
78 else if(SpeedTagVal == 79)
80 else if(SpeedTagVal == 96)
82 else if(SpeedTagVal == 129)
84 else if(SpeedTagVal == 130)
86 else if(SpeedTagVal == 131)
88 else if(SpeedTagVal == 145)
90 else if(SpeedTagVal == 146)
97 FixedNamedLocationElement(false)
99 for(
int x = 0; x < 4; x++)
110 AnsiString(VLocInput));
123 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
133 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
145 Graphics::TBitmap *GraphicOutput = GraphicPtr;
147 if(LocationName ==
"")
192 GraphicOutput = GraphicPtr;
196 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
205 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
206 AnsiString(TrainIDOnBridgeTrackPos01) +
"," + AnsiString(TrainIDOnBridgeTrackPos23) +
",EndTrkEl,";
215 if(lower.second < higher.second)
219 else if(lower.second > higher.second)
223 else if(lower.second == higher.second)
225 if(lower.first < higher.first)
238 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
239 CheckCount(9), IsARoute(false), AutoSignals(false), ConsecSignals(false)
243 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
254 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
282 {2, 4}, {6, 2}, {8, 6}, {4, 8},
283 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
291 else if(
Link[2] == -1)
300 else if(
Link[2] == -1)
308 for(
int x = 0; x < 16; x++)
310 if((Entry == EXArray[x][0]) && (Exit == EXArray[x][1]) || (Entry == EXArray[x][1]) && (Exit == EXArray[x][0]))
440 throw Exception(
"Error in EntryExitNumber 4");
516 throw Exception(
"Error in EntryExitNumber 5");
537 if(!AutoSigsFlag && !ConsecSignalsRoute)
590 throw Exception(
"Error in EntryExitNumber 6");
604 else if(!AutoSigsFlag && ConsecSignalsRoute)
657 throw Exception(
"Error in EntryExitNumber 10");
724 throw Exception(
"Error in EntryExitNumber 11");
797 throw Exception(
"Error in EntryExitNumber 7");
822 throw Exception(
"Error in EntryExitNumber 8");
833 if((ELink > 0) && (ELink < 10) && (ELink != 5))
835 if(!AutoSigsFlag && !ConsecSignalsRoute)
837 else if(!AutoSigsFlag && ConsecSignalsRoute)
844 throw Exception(
"Error in EntryExitNumber 9");
880 TTrack::TActiveLevelCrossing::TActiveLevelCrossing()
905 AnsiString NL =
'\n';
907 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable; " + NL + NL +
908 "reachable but with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
909 "blocked by a train, another route or a changing level crossing; " + NL + NL +
910 "or invalid - possibly due to a preferred direction mismatch or a missed signal in a green or blue route.";
917 int InternalLinkCheckArray[9][2] =
918 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
923 for(
int x = 0; x < 9; x++)
924 for(
int y = 0; y < 2; y++)
928 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
930 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
931 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
932 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
933 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27
934 << 60 << 61 << 62 << 63 << 68 << 69 << 70 << 71 << 80 << 81 << 82 << 83 << 125 << 126 << 127 << 128;
941 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
943 for(
int x = 0; x < 10; x++)
944 for(
int y = 0; y < 2; y++)
950 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
953 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
954 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
956 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
957 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
959 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
960 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
963 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
966 for(
int x = 0; x < 40; x++)
972 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
975 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
976 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
978 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
979 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
981 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
982 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
985 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
988 for(
int x = 0; x < 40; x++)
994 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
997 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
998 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1000 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1001 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1003 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1004 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1007 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1010 for(
int x = 0; x < 40; x++)
1036 for(
int x = 0; x < 40; x++)
1063 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1064 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1065 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1066 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1067 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1068 {0, 0, 129}, {0, -1, 145},
1071 for(
int x = 0; x < 25; x++)
1072 for(
int y = 0; y < 3; y++)
1077 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1078 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1079 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1080 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1081 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1082 {0, 0, 129}, {0, 1, 145},
1085 for(
int x = 0; x < 25; x++)
1086 for(
int y = 0; y < 3; y++)
1091 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1092 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1093 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1094 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1095 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1096 {0, 0, 130}, {-1, 0, 146},
1099 for(
int x = 0; x < 25; x++)
1100 for(
int y = 0; y < 3; y++)
1105 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1106 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1107 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1108 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1109 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1110 {0, 0, 130}, {1, 0, 146},
1113 for(
int x = 0; x < 25; x++)
1114 for(
int y = 0; y < 3; y++)
1119 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1120 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1121 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1122 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1123 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1124 {0, -1, 129}, {1, 0, 130},
1125 {-1, 0, 130}, {0, 1, 145},
1126 {0, -1, 145}, {1, 0, 146},
1129 for(
int x = 0; x < 28; x++)
1130 for(
int y = 0; y < 3; y++)
1145 for(
int x = 0; x < 8; x++)
1146 for(
int y = 0; y < 3; y++)
1161 for(
int x = 0; x < 8; x++)
1162 for(
int y = 0; y < 3; y++)
1177 for(
int x = 0; x < 8; x++)
1178 for(
int y = 0; y < 3; y++)
1193 for(
int x = 0; x < 8; x++)
1194 for(
int y = 0; y < 3; y++)
1199 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1201 for(
int x = 0; x < 4; x++)
1202 for(
int y = 0; y < 3; y++)
1206 {0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1207 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1208 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1209 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1210 140, 144, 145, 146};
1213 {0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1214 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1215 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1216 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1217 141, 144, 145, 146};
1220 {0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1221 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1222 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1223 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1224 141, 144, 146, 145};
1227 {0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1228 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1229 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1230 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1231 140, 144, 146, 145};
1251 delete UGMIt->second;
1325 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1326 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1328 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1335 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1336 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1349 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1350 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1352 {4, 6, 2, 8}, {1, 9, 3, 7},
1354 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1356 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8
1357 }, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1360 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1361 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6
1363 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1365 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1
1367 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1368 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1370 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1373 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1374 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1375 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1376 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1377 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1378 {4, 6, -1, -1}, {2, 8, -1, -1},
1380 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1382 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1384 {4, 6, -1, -1}, {2, 8, -1, -1},
1389 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1390 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1391 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1392 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1395 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1396 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1397 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1399 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1400 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1401 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1403 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1405 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1406 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1407 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1408 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1409 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1410 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1411 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1412 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet
1414 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1415 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1416 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet
1418 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1419 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1421 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1422 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1423 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1424 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1425 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1426 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1427 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1428 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1432 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1433 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1434 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1440 for(
int x = 0; x < 17; x++)
1442 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1444 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1448 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1454 ExistingGraphicLoaded(false), Width(16), Height(16)
1466 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1504 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1508 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1512 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1516 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1539 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1542 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1546 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1550 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1584 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1605 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1619 bool TrackPresent =
false;
1633 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1636 TrackPresent =
true;
1640 return !TrackPresent;
1648 bool TrackPresent =
false;
1657 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1660 TrackPresent =
true;
1665 return !TrackPresent;
1670 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
1673 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
1674 TrackEraseSuccessfulFlag =
false;
1679 ErasedTrackVectorPosition = -1;
1680 AnsiString SName =
"", ErrorString;
1682 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
1688 TrackMapKeyPair.first = HLocInput;
1689 TrackMapKeyPair.second = VLocInput;
1690 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
1701 if(ErrorString !=
"")
1703 throw Exception(ErrorString +
" for EraseTrackElement 1");
1726 ErasedTrackVectorPosition = VecPos;
1727 TrackEraseSuccessfulFlag =
true;
1734 unsigned int VecPos;
1735 InactiveTrackMapKeyPair.first = HLocInput;
1736 InactiveTrackMapKeyPair.second = VLocInput;
1741 VecPos = InactiveTrack2MultiMapIterator->second;
1746 if(ErrorString !=
"")
1748 throw Exception(ErrorString +
" for EraseTrackElement 2A");
1758 TrackEraseSuccessfulFlag =
true;
1778 VecPos = InactiveTrack2MultiMapIterator->second;
1783 if(ErrorString !=
"")
1785 throw Exception(ErrorString +
" for EraseTrackElement 2B");
1807 if(TrackEraseSuccessfulFlag)
1829 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
1830 bool PlatAllowedFlag =
false;
1832 TrackLinkingRequiredFlag =
false;
1844 LocationNameEntry.first =
"";
1853 TempTrackElement.
HLoc = HLocInput;
1854 TempTrackElement.
VLoc = VLocInput;
1880 else if(Aspect == 1)
1882 else if(Aspect == 2)
1884 else if(Aspect == 3)
1890 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
1893 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
1895 if(InactiveFoundFlag)
1898 NonStationOrLevelCrossingPresent =
true;
1900 NonStationOrLevelCrossingPresent =
true;
1902 PlatformPresent =
true;
1913 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
1920 PlatAllowedFlag =
true;
1924 PlatAllowedFlag =
true;
1928 PlatAllowedFlag =
true;
1932 PlatAllowedFlag =
true;
1936 TrackLinkingRequiredFlag =
true;
1963 if((FoundFlag && (
NameAllowed.Contains(
TrackVector.at(VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
1964 (!FoundFlag && !InactiveFoundFlag))
1967 TrackLinkingRequiredFlag =
true;
2000 TrackLinkingRequiredFlag =
true;
2012 else if(FoundFlag || InactiveFoundFlag)
2032 bool BothPointFillets =
true;
2046 TrackLinkingRequiredFlag =
true;
2059 bool InternalChecks)
2067 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2068 bool PlatAllowedFlag =
false;
2070 TrackLinkingRequiredFlag =
false;
2082 LocationNameEntry.first =
"";
2089 TempTrackElement.
HLoc = HLocInput;
2090 TempTrackElement.
VLoc = VLocInput;
2091 for(
int x = 0; x < 4; x++)
2095 TempTrackElement.
Conn[x] = -1;
2099 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2110 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2112 if(InactiveFoundFlag)
2115 NonStationOrLevelCrossingPresent =
true;
2117 NonStationOrLevelCrossingPresent =
true;
2119 PlatformPresent =
true;
2130 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2137 PlatAllowedFlag =
true;
2141 PlatAllowedFlag =
true;
2145 PlatAllowedFlag =
true;
2149 PlatAllowedFlag =
true;
2153 TrackLinkingRequiredFlag =
true;
2183 if((FoundFlag && (
NameAllowed.Contains(
TrackVector.at(VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2184 (!FoundFlag && !InactiveFoundFlag))
2187 TrackLinkingRequiredFlag =
true;
2223 TrackLinkingRequiredFlag =
true;
2235 else if(FoundFlag || InactiveFoundFlag)
2255 bool BothPointFillets =
true;
2269 TrackLinkingRequiredFlag =
true;
2297 ShowMessage(
"Gaps must be set before track can be validated");
2306 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2317 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2335 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2342 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2367 std::pair<AnsiString, char>TempMapPair;
2375 TempMapPair.second =
'x';
2388 int NewHLoc, NewVLoc;
2389 bool ConnectionFoundFlag, LinkFoundFlag;
2391 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2393 for(
unsigned int y = 0; y < 4; y++)
2405 ConnectionFoundFlag =
false;
2406 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2412 ConnectionFoundFlag =
true;
2414 LinkFoundFlag =
false;
2415 for(
unsigned int a = 0; a < 4; a++)
2419 LinkFoundFlag =
true;
2434 if(!ConnectionFoundFlag)
2507 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2522 bool UnsetGaps =
false;
2529 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2533 for(
unsigned int y = 0; y < 4; y++)
2545 for(
unsigned int y = 0; y < 4; y++)
2555 for(
unsigned int y = 1; y < 4; y++)
2564 for(
unsigned int y = 0; y < 4; y++)
2577 for(
unsigned int y = 0; y < 4; y++)
2604 int NumberOfActiveElements = 0;
2606 GraphicsFollow =
false;
2610 if(MarkerString[MarkerString.Length()] ==
'1')
2612 GraphicsFollow =
true;
2614 for(
int x = 0; x < NumberOfActiveElements; x++)
2620 TrackElement.
HLoc = TempInt;
2622 TrackElement.
VLoc = TempInt;
2628 TrackElement.
Conn[0] = TempInt;
2648 if((TempInt != -1) && (TempInt < 10))
2654 if((TempInt != -1) && (TempInt < 10))
2667 if(Marker[1] ==
'3')
2671 else if(Marker[1] ==
'2')
2675 else if(Marker[1] ==
'G')
2687 int NumberOfInactiveElements = 0;
2691 for(
int x = 0; x < NumberOfInactiveElements; x++)
2697 TrackElement.
HLoc = TempInt;
2699 TrackElement.
VLoc = TempInt;
2705 bool LocError =
false;
2734 for(
int x = 0; x < NumberOfGraphics; x++)
2745 bool FileError =
false;
2747 for(
int x = 0; x < NumberOfGraphics; x++)
2760 UGME.second =
new TPicture;
2761 UGME.second->LoadFromFile(
UGME.first);
2764 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
2771 catch(
const EInvalidGraphic &e)
2780 delete UGMIt->second;
2785 catch(
const Exception &e)
2794 delete UGMIt->second;
2802 bool FoundInMap =
false;
2821 UGME.second =
new TPicture;
2822 UGME.second->LoadFromFile(
UGME.first);
2825 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
2832 catch(
const EInvalidGraphic &e)
2841 delete UGMIt->second;
2846 catch(
const Exception &e)
2855 delete UGMIt->second;
2880 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
2884 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
2886 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
2889 VecFile << x <<
'\n';
2890 VecFile << TrackElement.
SpeedTag <<
'\n';
2891 VecFile << TrackElement.
HLoc <<
'\n';
2892 VecFile << TrackElement.
VLoc <<
'\n';
2896 VecFile << TrackElement.
Conn[0] <<
'\n';
2900 VecFile << TrackElement.
Attribute <<
'\n';
2905 VecFile << int(1) <<
'\n';
2907 VecFile << int(0) <<
'\n';
2909 VecFile << TrackElement.
Length01 <<
'\n';
2910 VecFile << TrackElement.
Length23 <<
'\n';
2913 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
2920 VecFile <<
"3*****" <<
'\0' <<
'\n';
2924 VecFile <<
"2*****" <<
'\0' <<
'\n';
2928 VecFile <<
"G*****" <<
'\0' <<
'\n';
2932 VecFile <<
"4*****" <<
'\0' <<
'\n';
2937 VecFile <<
"******" <<
'\0' <<
'\n';
2942 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
2946 VecFile << x <<
'\n';
2947 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
2948 VecFile << InactiveTrackElement.
HLoc <<
'\n';
2949 VecFile << InactiveTrackElement.
VLoc <<
'\n';
2950 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
2951 VecFile <<
"******" <<
'\0' <<
'\n';
2966 GraphicsFollow =
false;
2968 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
2974 AnsiString MarkerString;
2981 if(MarkerString[MarkerString.Length()] ==
'1')
2983 GraphicsFollow =
true;
2985 for(
int x = 0; x < NumberOfActiveElements; x++)
2993 int SpeedTag = TempInt;
3000 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3006 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3011 if((SpeedTag > 87) && (SpeedTag < 96))
3014 if((TempInt < -1) || (TempInt > 3))
3020 if((TempInt < -1) || (TempInt > 999999))
3026 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3027 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3030 if((TempInt < -1) || (TempInt > 5))
3036 if((SpeedTag >= 68) && (SpeedTag <= 75))
3039 if((TempInt != 0) && (TempInt != 1))
3046 if((TempInt < -1) || (TempInt > 999999))
3052 if((TempInt < -1) || (TempInt > 999999))
3058 if((TempInt < -1) || (TempInt > 999999))
3064 if((TempInt < -1) || (TempInt > 999999))
3085 int NumberOfInactiveElements = 0;
3088 if(NumberOfInactiveElements < 0)
3098 for(
int x = 0; x < NumberOfInactiveElements; x++)
3112 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3118 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3145 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3151 AnsiString FileName =
"", TempStr =
"";
3153 for(
int x = 0; x < NumberOfGraphics; x++)
3155 TPicture *TempPicture =
new TPicture;
3164 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3177 catch(
const EInvalidGraphic &e)
3182 for(
int y = x + 1; y < NumberOfGraphics; y++)
3188 ShowMessage(FileName +
3189 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3194 catch(
const Exception &e)
3199 for(
int y = x + 1; y < NumberOfGraphics; y++)
3205 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3206 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3224 for(
int x = 0; x < VecSize; x++)
3247 for(
int x = 0; x < VecSize; x++)
3269 for(
int x = 0; x < VecSize; x++)
3323 for(
int x = 0; x < VecSize; x++)
3380 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3391 if(BothPointFilletsAndBasicLCs)
3466 Bitmap->Canvas->CopyMode = cmSrcCopy;
3468 Graphics::TBitmap *GraphicOutput;
3639 for(
int x = 0; x < 40; x++)
3658 Graphics::TBitmap *GraphicPtr;
3667 Graphics::TBitmap* SignalPlatformGraphic;
3700 if(OldTransparentColour !=
clB5G5R5)
3723 Bitmap->Canvas->CopyMode = cmSrcCopy;
3751 Bitmap->Canvas->CopyMode = cmSrcCopy;
3753 Graphics::TBitmap *GraphicOutput;
3763 if(BaseElement == 1)
3851 for(
int x = 0; x < 40; x++)
3870 Graphics::TBitmap *GraphicPtr;
3879 Graphics::TBitmap* SignalPlatformGraphic;
3940 for(
int x = 0; x < 40; x++)
3948 Graphics::TBitmap* SignalPlatformGraphic;
3969 if(OldTransparentColour !=
clB5G5R5)
3983 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4053 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4067 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4092 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4117 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4147 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4181 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4217 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4232 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4262 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4269 throw Exception(
"Error - Map & Vector different sizes");
4271 unsigned int NonZeroCount = 0;
4273 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4280 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4287 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4291 TrackMapEntry.first = TrackMapKeyPair;
4292 TrackMapEntry.second = x;
4293 if(!(
TrackMap.insert(TrackMapEntry).second))
4295 throw Exception(
"Error - map insertion failure, TrackVector in error");
4299 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4301 for(
unsigned int y = 0; y < 4; y++)
4326 THVPair GapMapKeyPair, GapMapValuePair;
4329 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4335 GapMapEntry.first = GapMapKeyPair;
4338 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4342 GapMapEntry.second = GapMapValuePair;
4345 GapMap.insert(GapMapEntry);
4358 bool CheckForLinks =
false;
4360 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4370 "Footbridge or underpass connection error. Each end must connect to a platform, concourse or other footbridge or underpass, and they can't connect to each other");
4378 for(
unsigned int y = 0; y < 4; y++)
4380 CheckForLinks =
false;
4392 bool ConnectionFoundFlag;
4396 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4402 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4409 if(ConnectionFoundFlag)
4413 bool LinkFoundFlag =
false;
4416 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
4422 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
4428 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
4436 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
4442 ShowMessage(
"Signal facing a bridge - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
4449 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
4452 CheckForLinks =
true;
4455 for(
unsigned int a = 0; a < 4; a++)
4464 LinkFoundFlag =
true;
4477 throw Exception(
"Error in final track linkage - invalid link");
4491 throw Exception(
"Error in final track linkage - connection not found");
4503 bool ConnErrorFlag =
false;
4505 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4508 ConnErrorFlag =
true;
4510 ConnErrorFlag =
true;
4512 ConnErrorFlag =
true;
4514 ConnErrorFlag =
true;
4517 if(
TrackVector.at(x).ActiveTrackElementName ==
"")
4519 if((
TrackVector.at(x).StationEntryStopLinkPos1 != -1) || (
TrackVector.at(x).StationEntryStopLinkPos2 != -1))
4521 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
4530 throw Exception(
"ConnError in LinkTrack - Final");
4534 throw Exception(
"ConnError in LinkTrack - Precheck");
4538 bool CLkErrorFlag =
false;
4540 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4543 CLkErrorFlag =
true;
4545 CLkErrorFlag =
true;
4547 CLkErrorFlag =
true;
4549 CLkErrorFlag =
true;
4556 throw Exception(
"CLkError in LinkTrack - Final");
4560 throw Exception(
"CLkError in LinkTrack - Precheck");
4565 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4588 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4603 for(
unsigned int y = 0; y < 4; y++)
4616 bool ConnectionFoundFlag;
4622 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4629 if(ConnectionFoundFlag)
4632 bool LinkFoundFlag =
false;
4689 for(
unsigned int a = 0; a < 4; a++)
4698 LinkFoundFlag =
true;
4706 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
4716 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
4728 bool ConnErrorFlag =
false;
4730 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4733 ConnErrorFlag =
true;
4735 ConnErrorFlag =
true;
4737 ConnErrorFlag =
true;
4739 ConnErrorFlag =
true;
4742 if(
TrackVector.at(x).ActiveTrackElementName ==
"")
4744 if((
TrackVector.at(x).StationEntryStopLinkPos1 != -1) || (
TrackVector.at(x).StationEntryStopLinkPos2 != -1))
4746 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
4755 throw Exception(
"ConnError in LinkTrack - Final");
4759 throw Exception(
"ConnError in LinkTrack - Precheck");
4763 bool CLkErrorFlag =
false;
4765 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4768 CLkErrorFlag =
true;
4770 CLkErrorFlag =
true;
4772 CLkErrorFlag =
true;
4774 CLkErrorFlag =
true;
4781 throw Exception(
"CLkError in LinkTrack - Final");
4785 throw Exception(
"CLkError in LinkTrack - Precheck");
4790 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4813 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4831 for(
unsigned int y = 0; y < 4; y++)
4844 bool ConnectionFoundFlag =
false;
4846 if(ConnectionFoundFlag)
4850 bool LinkFoundFlag =
false;
4870 for(
unsigned int a = 0; a < 4; a++)
4879 LinkFoundFlag =
true;
4899 bool ConnErrorFlag =
false;
4901 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4904 ConnErrorFlag =
true;
4906 ConnErrorFlag =
true;
4908 ConnErrorFlag =
true;
4910 ConnErrorFlag =
true;
4918 bool CLkErrorFlag =
false;
4920 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4923 CLkErrorFlag =
true;
4925 CLkErrorFlag =
true;
4927 CLkErrorFlag =
true;
4929 CLkErrorFlag =
true;
4946 int Position1, Position2;
4952 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
4954 int HLoc1 = GapMapPtr->first.first;
4955 int VLoc1 = GapMapPtr->first.second;
4956 int HLoc2 = GapMapPtr->second.first;
4957 int VLoc2 = GapMapPtr->second.second;
4960 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
4964 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
4968 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
4972 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
4990 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
4991 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5001 bool FoundFlag =
false;
5013 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5014 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5015 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5036 bool FoundFlag =
false;
5049 TrackMapKeyPair.first = TrackElement.
HLoc;
5050 TrackMapKeyPair.second = TrackElement.
VLoc;
5051 TrackMapEntry.first = TrackMapKeyPair;
5056 LocationNameEntry.second = -(int)(
TrackVector.size());
5088 TrackMapKeyPair.first = HLoc;
5089 TrackMapKeyPair.second = VLoc;
5090 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5100 return TrackMapPtr->second;
5113 TrackMapKeyPair.first = HLoc;
5114 TrackMapKeyPair.second = VLoc;
5115 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5118 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5119 throw Exception(Message);
5134 THVPair InactiveTrackMapKeyPair;
5137 InactiveTrackMapKeyPair.first = HLoc;
5138 InactiveTrackMapKeyPair.second = VLoc;
5142 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5143 throw Exception(Message);
5157 bool Present =
true;
5161 TrackMapKeyPair.first = HLoc;
5162 TrackMapKeyPair.second = VLoc;
5163 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5178 bool Present =
true;
5179 THVPair InactiveTrackMapKeyPair;
5182 InactiveTrackMapKeyPair.first = HLoc;
5183 InactiveTrackMapKeyPair.second = VLoc;
5201 THVPair InactiveTrackMapKeyPair;
5206 InactiveTrackMapKeyPair.first = HLoc;
5207 InactiveTrackMapKeyPair.second = VLoc;
5216 if(InactiveTrackRange.first == InactiveTrackRange.second)
5225 RetPair.first = InactiveTrackRange.first->second;
5226 RetPair.second = (--InactiveTrackRange.second)->second;
5239 AnsiString(DivergingPosition));
5250 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
5251 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
5252 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
5253 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
5254 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
5255 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
5256 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
5257 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
5258 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
5259 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
5260 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
5261 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
5295 throw Exception(
"Error, Wrong track type in PlotGap");
5297 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
5301 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
5305 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
5309 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
5313 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
5317 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
5321 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
5325 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
5329 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
5333 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
5337 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
5341 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
5345 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
5349 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
5353 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
5357 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
5371 throw Exception(
"Error, Wrong track type in PlotPoints");
5382 else if(TrackElement.
SpeedTag < 132)
5400 else if(TrackElement.
SpeedTag < 132)
5432 throw Exception(
"Error, Wrong track type in PlotSignal");
5434 for(
int x = 0; x < 40; x++)
5505 for(
int x = 0; x < 40; x++)
5512 Graphics::TBitmap* SignalPlatformGraphic;
5599 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
5607 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
5615 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
5623 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
5639 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
5647 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
5655 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
5663 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
5695 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
5707 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
5719 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
5731 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
5773 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
5775 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
5777 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
5780 if(BaseElementSpeedTag == 1)
5784 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
5791 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
5799 Graphics::TBitmap *RouteGraphic;
5801 if(ConsecSignals == 1)
5805 else if(ConsecSignals == 0)
5811 RouteGraphic = BaseGraphic;
5818 if(UpStep == DownStep)
5821 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
5831 else if((DownStep - UpStep) == 1)
5836 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
5846 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5859 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5869 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
5885 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
5895 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5905 else if(DownStep == 0)
5908 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5918 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
5931 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5941 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5951 for(
int x = (UpStep + 1); x < DownStep; x++)
5955 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
5957 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
5977 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
5984 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
5990 Graphics::TBitmap *RouteGraphic;
5992 if(ConsecSignals == 1)
5996 else if(ConsecSignals == 0)
6002 RouteGraphic = BaseGraphic;
6011 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6021 else if((RStep - LStep) == 1)
6026 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6036 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6049 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6059 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6075 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6085 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6098 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6108 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6121 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6131 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6141 for(
int x = (LStep + 1); x < RStep; x++)
6146 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
6150 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
6174 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6177 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6179 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6181 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6184 if(BaseElementSpeedTag == 1)
6188 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
6195 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
6201 if(UpStep == DownStep)
6212 else if((DownStep - UpStep) == 1)
6231 for(
int x = (UpStep + 1); x < DownStep; x++)
6240 for(
int x = (UpStep + 1); x < DownStep; x++)
6247 for(
int x = UpStep; x <= DownStep; x++)
6260 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
6267 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
6284 else if((RStep - LStep) == 1)
6303 for(
int x = (LStep + 1); x < RStep; x++)
6312 for(
int x = (LStep + 1); x < RStep; x++)
6319 for(
int x = LStep; x <= RStep; x++)
6338 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
6340 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6342 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
6345 if(BaseElementSpeedTag == 1)
6349 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
6356 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
6362 for(
int x = UpStep; x < (DownStep + 1); x++)
6377 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
6384 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
6390 for(
int x = LStep; x < (RStep + 1); x++)
6409 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6412 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6414 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6416 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6421 if(BaseElementSpeedTag == 1)
6425 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
6432 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
6438 for(
int x = UpStep; x <= DownStep; x++)
6452 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
6459 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
6465 for(
int x = LStep; x <= RStep; x++)
6481 Graphics::TBitmap *RouteGraphic;
6484 if(BaseElementSpeedTag == 1)
6486 if(ConsecSignals == 1)
6490 else if(ConsecSignals == 0)
6496 RouteGraphic = BaseGraphic;
6500 RouteGraphic = BaseGraphic;
6505 if(ConsecSignals == 1)
6509 else if(ConsecSignals == 0)
6515 RouteGraphic = BaseGraphic;
6518 RouteGraphic = BaseGraphic;
6522 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
6526 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6528 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6534 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
6537 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6542 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
6546 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
6548 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
6554 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
6557 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
6682 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
6686 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
6717 "," + AnsiString(VLoc));
6721 int DummyRouteNumber;
6723 TrainPresent =
false;
6727 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
6729 TrackMapKeyPair.first = HLoc;
6730 TrackMapKeyPair.second = VLoc + UpStep;
6731 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6740 TrainPresent =
true;
6749 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
6751 TrackMapKeyPair.first = HLoc;
6752 TrackMapKeyPair.second = VLoc + DownStep;
6753 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6762 TrainPresent =
true;
6771 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
6773 TrackMapKeyPair.first = HLoc + LeftStep;
6774 TrackMapKeyPair.second = VLoc;
6775 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6784 TrainPresent =
true;
6793 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
6795 TrackMapKeyPair.first = HLoc + RightStep;
6796 TrackMapKeyPair.second = VLoc;
6797 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6806 TrainPresent =
true;
6823 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
6830 else if(TrackElement.
SpeedTag < 132)
6848 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
6865 AnsiString(ScreenPosV));
6880 AnsiString(ScreenPosV));
6891 AnsiString(VPosTrue));
6905 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
6917 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
6918 " in TrackMap, Caller=" + (AnsiString)Caller);
6920 if(MapVecPos != (
int)a)
6922 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
6923 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
6924 (AnsiString)Caller);
6930 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
6931 " Caller=" + (AnsiString)Caller);
6951 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
6952 " in InactiveMap, Caller=" + (AnsiString)Caller);
6954 if((InactivePair.first != a) && (InactivePair.second != a))
6956 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
6957 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
6958 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
6963 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
6964 " Caller=" + (AnsiString)Caller);
6974 int Position1, Position2;
6980 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
6982 int HLoc1 = GapMapPtr->first.first;
6983 int VLoc1 = GapMapPtr->first.second;
6984 int HLoc2 = GapMapPtr->second.first;
6985 int VLoc2 = GapMapPtr->second.second;
6988 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
6992 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
6996 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
7000 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
7004 unsigned int GapCount = 0;
7006 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7012 if((
GapMap.size() * 2) != GapCount)
7014 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
7015 (AnsiString)Caller);
7025 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
7029 throw Exception(
"Error - TrackFinished with erase element still present");
7034 AnsiString IDString;
7036 if(TrackElement.
HLoc < 0)
7037 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
7039 IDString = AnsiString(TrackElement.
HLoc) +
"-";
7040 if(TrackElement.
VLoc < 0)
7041 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
7043 IDString += AnsiString(TrackElement.
VLoc);
7056 for(
int x = 1; x < String.Length() + 1; x++)
7058 if(String.IsDelimiter(
"-", x))
7063 if(x == String.Length())
7066 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
7074 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
7078 if(DelimPos == String.Length())
7081 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
7085 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
7088 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
7094 if(String.SubString(1, 1) !=
"N")
7096 for(
int x = 1; x < DelimPos; x++)
7098 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7101 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7107 if(String.SubString(1, 1) ==
"N")
7109 for(
int x = 2; x < DelimPos; x++)
7111 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7114 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7120 if(String.SubString(1, 1) ==
"N")
7121 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
7123 HLoc = String.SubString(1, DelimPos - 1).ToInt();
7125 if(String.SubString(DelimPos + 1, 1) !=
"N")
7127 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
7129 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7132 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7138 if(String.SubString(DelimPos + 1, 1) ==
"N")
7140 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
7142 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7145 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7151 if(String.SubString(DelimPos + 1, 1) ==
"N")
7152 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
7154 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
7159 TrackMapPtr =
TrackMap.find(HVPair);
7163 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
7168 return TrackMapPtr->second;
7179 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
7180 int HLoc = TrackElement.
HLoc;
7181 int VLoc = TrackElement.
VLoc;
7284 AnsiString(SpeedTag));
7295 if(HVRange.first == HVRange.second)
7301 HVIt1 = HVRange.first;
7305 if(--HVRange.second != HVRange.first)
7307 HVIt2 = HVRange.second;
7311 HVIt2->second).
SpeedTag == SpeedTag)))
7331 AnsiString(SpeedTag));
7397 AnsiString TestString1, TestString2;
7402 throw Exception(
"LNPendingList size not 1 on entry");
7404 int CurrentElementNumber;
7410 int H = CurrentElement->HLoc;
7411 int V = CurrentElement->VLoc;
7412 int Tag = CurrentElement->SpeedTag;
7418 for(
int x = 0; x < 25; x++)
7428 for(
int x = 0; x < 25; x++)
7438 for(
int x = 0; x < 25; x++)
7448 for(
int x = 0; x < 25; x++)
7458 for(
int x = 0; x < 28; x++)
7468 for(
int x = 0; x < 8; x++)
7478 for(
int x = 0; x < 8; x++)
7488 for(
int x = 0; x < 4; x++)
7498 for(
int x = 0; x < 8; x++)
7508 for(
int x = 0; x < 8; x++)
7521 if(CurrentElementNumber > -1)
7526 if((ExistingName !=
"") && (ExistingName != LocationName))
7540 AddName(1, CurrentElement, LocationName);
7544 LNDone2MultiMapEntry.first = HVPair;
7555 bool FoundFlag, ErasedFlag =
false;
7557 if(SNRange.first != SNRange.second)
7561 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
7568 TVIt->LocationName =
"";
7569 TVIt->ActiveTrackElementName =
"";
7598 std::pair<AnsiString, char>TempMapPair;
7606 TempMapPair.second =
'x';
7624 AnsiString(SpeedTag));
7634 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
7641 int MapPos = -1 - Position;
7645 FoundElement = MapPos;
7661 FoundElement = IMPair.first;
7670 FoundElement = IMPair.second;
7691 AnsiString OldName = TrackElement->LocationName, ErrorString;
7693 TrackElement->LocationName = Name;
7694 int HLoc = TrackElement->HLoc;
7695 int VLoc = TrackElement->VLoc;
7709 if(ErrorString !=
"")
7711 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
7735 if(LNDone2MultiMapIterator->second == MapPos)
7762 if(*LNPendingListIterator == MapPos)
7839 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
7846 NameBeingChecked = LNMMRg.second->first;
7852 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
7872 if(LNMMIt->second < 0)
7882 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
7890 std::list<THVPair> HVLinkedList;
7893 HVPairsLinkedMap.begin()->second =
true;
7894 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
7897 THVPair HVPairUnderExamination;
7898 THVPairsLinkedMap::iterator HVPLMIt;
7900 while(!HVLinkedList.empty())
7902 HVPairUnderExamination = HVLinkedList.front();
7903 HVLinkedList.pop_front();
7904 HVPairNew.first = HVPairUnderExamination.first;
7905 HVPairNew.second = HVPairUnderExamination.second - 1;
7906 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
7907 if(HVPLMIt != HVPairsLinkedMap.end())
7909 if(!HVPLMIt->second)
7911 HVLinkedList.push_back(HVPLMIt->first);
7913 HVPLMIt->second =
true;
7915 HVPairNew.first = HVPairUnderExamination.first - 1;
7916 HVPairNew.second = HVPairUnderExamination.second;
7917 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
7918 if(HVPLMIt != HVPairsLinkedMap.end())
7920 if(!HVPLMIt->second)
7922 HVLinkedList.push_back(HVPLMIt->first);
7924 HVPLMIt->second =
true;
7926 HVPairNew.first = HVPairUnderExamination.first;
7927 HVPairNew.second = HVPairUnderExamination.second + 1;
7928 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
7929 if(HVPLMIt != HVPairsLinkedMap.end())
7931 if(!HVPLMIt->second)
7933 HVLinkedList.push_back(HVPLMIt->first);
7935 HVPLMIt->second =
true;
7937 HVPairNew.first = HVPairUnderExamination.first + 1;
7938 HVPairNew.second = HVPairUnderExamination.second;
7939 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
7940 if(HVPLMIt != HVPairsLinkedMap.end())
7942 if(!HVPLMIt->second)
7944 HVLinkedList.push_back(HVPLMIt->first);
7946 HVPLMIt->second =
true;
7951 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
7953 if(!HVPLMIt->second)
7972 if(LocationName ==
"")
7983 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7988 ActiveTrackElementNameMapEntry.first =
Track->
TrackVector.at(x).ActiveTrackElementName;
7989 ActiveTrackElementNameMapEntry.second = 0;
8011 bool FoundFlag, ErasedFlag =
false;
8015 if(SNRange.first != SNRange.second)
8018 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
8021 TVIt->LocationName =
"";
8022 TVIt->ActiveTrackElementName =
"";
8054 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
8056 AnsiString LocationName;
8065 if(LocationName !=
"")
8073 if(LocationName !=
"")
8087 if(LocationName !=
"")
8089 int ModifiedPosition = -1 - Position;
8099 for(
int x = 0; x < 25; x++)
8109 else if(SpeedTag == 77)
8111 for(
int x = 0; x < 25; x++)
8121 else if(SpeedTag == 78)
8123 for(
int x = 0; x < 25; x++)
8133 else if(SpeedTag == 79)
8135 for(
int x = 0; x < 25; x++)
8145 else if(SpeedTag == 96)
8147 for(
int x = 0; x < 28; x++)
8157 else if(SpeedTag == 129)
8159 for(
int x = 0; x < 8; x++)
8169 else if(SpeedTag == 130)
8171 for(
int x = 0; x < 8; x++)
8181 else if(SpeedTag == 145)
8183 for(
int x = 0; x < 8; x++)
8193 else if(SpeedTag == 146)
8195 for(
int x = 0; x < 8; x++)
8205 else if(SpeedTag == 131)
8207 for(
int x = 0; x < 4; x++)
8230 AnsiString(SpeedTag));
8242 if(TempElement->LocationName !=
"")
8244 LocationName = TempElement->LocationName;
8245 FoundElement = IMPair.first;
8253 if(TempElement->LocationName !=
"")
8255 LocationName = TempElement->LocationName;
8256 FoundElement = IMPair.second;
8269 if(TempElement->LocationName !=
"")
8271 LocationName = TempElement->LocationName;
8272 FoundElement = -1 - Position;
8288 unsigned int Count = 0;
8296 AnsiString SName, TName, ErrorString;
8298 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8304 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
8305 AnsiString(Caller));
8318 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
8319 AnsiString(Caller));
8326 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
8327 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8333 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8339 if(ErrorString !=
"")
8341 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
8343 if(SNIt->second != -1 - (
int)x)
8345 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
8346 AnsiString(Caller));
8352 bool FoundFlag =
false;
8361 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackVector.at(x).HLoc) +
" & V " +
8362 AnsiString(
TrackVector.at(x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8366 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackVector.at(x).HLoc) +
8367 " & V " + AnsiString(
TrackVector.at(x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
8368 AnsiString(Caller));
8373 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackVector.at(x).HLoc) +
" & V " +
8374 AnsiString(
TrackVector.at(x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8384 if(ErrorString !=
"")
8386 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
8388 if(SNIt->second != (
int)x)
8390 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
8391 AnsiString(Caller));
8401 AnsiString &ErrorString)
8409 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
8411 bool FoundFlag =
false;
8415 if(SNRange.first == SNRange.second)
8417 ErrorString =
"Error, Name " + LocationName +
" not found in map";
8419 return SNRange.first;
8423 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
8425 if(SNIterator->second < 0)
8427 int TVPos = -1 - SNIterator->second;
8429 if(TVIt == TrackElement)
8438 int ITVPos = SNIterator->second;
8440 if(ITVIt == TrackElement)
8450 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
8466 LocationNameEntry.first = NewName;
8467 LocationNameEntry.second = SNIterator->second;
8481 int TruePos = -1 - Position;
8485 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
8495 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
8518 InactiveTrack2MultiMapIterator++)
8520 if(InactiveTrack2MultiMapIterator->second > VecPos)
8521 InactiveTrack2MultiMapIterator->second--;
8528 LocationNameMultiMapIterator++)
8530 if(LocationNameMultiMapIterator->second < 0)
8532 if(LocationNameMultiMapIterator->second > (
int)VecPos)
8533 LocationNameMultiMapIterator->second--;
8554 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
8556 if(TrackMapIterator->second > VecPos)
8557 TrackMapIterator->second--;
8564 LocationNameMultiMapIterator++)
8566 if(LocationNameMultiMapIterator->second >= 0)
8570 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
8571 LocationNameMultiMapIterator->second++;
8574 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8580 if(TkEl.
Conn[0] ==
int(VecPos))
8585 if(TkEl.
Conn[0] >
int(VecPos))
8587 if(TkEl.
Conn[0] > -1)
8611 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
8617 LocationNameEntry.second = -1 - TVPos;
8628 LocationNameEntry.second = ITVPos;
8670 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8702 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8726 AnsiString((
short)FirstTrack));
8727 bool LengthDifferent =
false, SpeedDifferent =
false;
8735 int EXArray[16][2] =
8737 {2, 4}, {6, 2}, {8, 6}, {4, 8},
8738 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
8741 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
8742 Graphics::TBitmap *Bitmap;
8746 InLink = TrackElement.
Link[0];
8747 OutLink = TrackElement.
Link[1];
8751 InLink = TrackElement.
Link[2];
8752 OutLink = TrackElement.
Link[3];
8755 for(
int x = 0; x < 16; x++)
8757 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
8762 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
8780 else if(TrackElement.
SpeedTag == 54)
8782 else if(TrackElement.
SpeedTag == 55)
8789 else if(TrackElement.
SpeedTag == 58)
8791 else if(TrackElement.
SpeedTag == 59)
8794 else if(Index == 14)
8798 else if(TrackElement.
SpeedTag == 52)
8800 else if(TrackElement.
SpeedTag == 57)
8803 else if(Index == 15)
8807 else if(TrackElement.
SpeedTag == 53)
8809 else if(TrackElement.
SpeedTag == 56)
8819 if(LengthDifferent && SpeedDifferent)
8860 else if(LengthDifferent && !SpeedDifferent)
8954 AnsiString((
short)FirstTrack));
8955 LengthDifferent =
false;
8956 SpeedDifferent =
false;
8961 LengthDifferent =
true;
8965 SpeedDifferent =
true;
8967 if(LengthDifferent || SpeedDifferent)
8980 LengthDifferent =
true;
8984 SpeedDifferent =
true;
8986 if(LengthDifferent || SpeedDifferent)
8999 LengthDifferent =
true;
9003 SpeedDifferent =
true;
9005 if(LengthDifferent || SpeedDifferent)
9085 AnsiString TempName;
9086 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
9087 bool ForwardSet, ReverseSet;
9089 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9094 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9132 for(
int y = 0; y < 2; y++)
9163 StartElement = TempElement;
9164 StartVecPos = VecPos;
9168 StartEntryPos = 1 - Dir;
9177 VecPos = TempElement.
Conn[1 - EntryPos];
9178 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
9180 EntryPos = TempEntryPos;
9208 ForwardNumber = ((Count + 1) / 2) + 1;
9209 ReverseNumber = (Count - ForwardNumber) + 1;
9212 TempElement = StartElement;
9213 VecPos = StartVecPos;
9214 if(Count == ForwardNumber)
9219 if(Count == ReverseNumber)
9227 VecPos = TempElement.
Conn[1 - EntryPos];
9228 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
9230 EntryPos = TempEntryPos;
9232 if(Count == ForwardNumber)
9237 if(Count == ReverseNumber)
9249 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9251 if(
TrackVector.at(x).StationEntryStopLinkPos1 == 5)
9255 if(
TrackVector.at(x).StationEntryStopLinkPos2 == 5)
9363 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9399 if((TextH / 16) - 1 <
HLocMin)
9401 if((TextH / 16) + 1 >
HLocMax)
9403 if((TextV / 16) - 1 <
VLocMin)
9405 if((TextV / 16) + 1 >
VLocMax)
9425 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
9426 bool &UserGraphicFoundFlag)
9429 TUserGraphicVector::iterator UserGraphicPtr;
9431 UserGraphicFoundFlag =
false;
9438 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
9439 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
9441 UserGraphicItem = x;
9442 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
9443 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
9444 UserGraphicFoundFlag =
true;
9460 int SpeedTag = TrackElement.
SpeedTag;
9464 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
9513 return GraphicOutput;
9521 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
9523 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
9536 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
9537 " in InactiveTrackElementAt");
9548 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
9550 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
9575 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
9576 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
9580 if(SNRange.first == SNRange.second)
9585 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9587 if(SNIterator->second < 0)
9593 HVPair.first = InactiveElement.
HLoc;
9594 HVPair.second = InactiveElement.
VLoc;
9598 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNamedLocationLongEnoughForSplit (1)");
9600 int TVPos =
TrackMap.find(HVPair)->second;
9603 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
9609 FirstNamedExitPos = 0;
9613 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9614 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9617 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9619 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
9620 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9621 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9624 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9634 FirstNamedExitPos = 1;
9638 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9639 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9642 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9644 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
9645 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9646 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9649 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9664 int &FirstNamedLinkedElementPos,
int &SecondNamedLinkedElementPos)
9678 AnsiString(FirstNamedElementPos));
9679 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
9680 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
9682 SecondNamedElementPos = -1;
9683 FirstNamedLinkedElementPos = -1;
9684 SecondNamedLinkedElementPos = -1;
9688 if(SNRange.first == SNRange.second)
9693 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9695 if(SNIterator->second < 0)
9701 HVPair.first = InactiveElement.
HLoc;
9702 HVPair.second = InactiveElement.
VLoc;
9714 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in ThisNamedLocationLongEnoughForSplit (2)"
9718 int TVPos =
TrackMap.find(HVPair)->second;
9719 if(TVPos != FirstNamedElementPos)
9723 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
9729 FirstNamedExitPos = 0;
9733 FirstNamedLinkedElement =
TrackElementAt(569, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9734 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9737 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9739 SecondNamedLinkedElement =
TrackElementAt(570, SecondNamedElement.
Conn[SecondNamedExitPos]);
9740 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9741 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9744 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9746 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
9747 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
9748 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
9757 FirstNamedExitPos = 1;
9761 FirstNamedLinkedElement =
TrackElementAt(572, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9762 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9765 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9767 SecondNamedLinkedElement =
TrackElementAt(573, SecondNamedElement.
Conn[SecondNamedExitPos]);
9768 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9769 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9772 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9774 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
9775 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
9776 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
9796 if(SNRange.first != SNRange.second)
9798 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9800 if(SNIterator->second < 0)
9820 "," + AnsiString(SpeedTag));
9831 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
9857 else if(SpeedTag == 69)
9879 else if(SpeedTag == 70)
9901 else if(SpeedTag == 71)
9934 AnsiString(NextEntryPos) +
"," + AnsiString(OwnTrainID));
9935 if(NextEntryPos < 0)
9948 if(NextEntryPos > 1)
9967 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
9979 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
9980 bool FoundFlag =
false;
9995 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
9996 bool FoundFlag =
false;
10015 VPosHi = 16 * VLocHi;
10016 VPosLo = 16 * VLocLo;
10035 AnsiString(EndTVPosition));
10046 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
10047 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
10048 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
10049 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
10051 if(Link0Squares <= Link1Squares)
10068 AnsiString(LinkPos));
10087 if((LinkPos == 1) && (TE.
Attribute == 0))
10092 else if(LinkPos == 1)
10098 else if((LinkPos == 3) && (TE.
Attribute == 1))
10103 else if(LinkPos == 3)
10110 else if(LinkPos == 0)
10115 else if(LinkPos == 1)
10120 else if(LinkPos == 2)
10125 else if(LinkPos == 3)
10130 throw Exception(
"Error, failure in GetExitPos");
10179 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
10183 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
10223 "," + AnsiString(DiagonalLinkNumber));
10228 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
10234 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
10240 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
10246 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
10263 AnsiString JustFileName =
"";
10268 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
10275 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
10294 typedef std::list<int> TNamePosList;
10295 TNamePosList NamePosList;
10296 typedef TNamePosList::iterator TNPLIt;
10298 typedef std::list<int> TOnePlatList;
10299 TOnePlatList OnePlatList;
10300 typedef TOnePlatList::iterator TOPLIt;
10303 NamePosList.clear();
10304 OnePlatList.clear();
10305 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10307 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
10309 NamePosList.push_back(x);
10314 if(!NamePosList.empty())
10316 OnePlatList.push_back(NamePosList.back());
10317 NamePosList.pop_back();
10320 while(!OnePlatList.empty())
10322 TempInt = OnePlatList.front();
10325 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
10326 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
10328 OnePlatList.push_back(TempElement.
Conn[0]);
10329 NamePosList.erase(NPLIt);
10331 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
10332 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
10334 OnePlatList.push_back(TempElement.
Conn[1]);
10335 NamePosList.erase(NPLIt);
10338 OnePlatList.erase(OnePlatList.begin());
10339 if(OnePlatList.empty())
10342 if(!NamePosList.empty())
10344 OnePlatList.push_back(NamePosList.back());
10345 NamePosList.pop_back();
10362 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
10377 throw Exception(
"Return value negative in call to LastElementNumber");
10389 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
10403 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
10415 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
10416 " in GetModifiablePrefDirElementAt");
10426 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
10428 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
10438 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
10440 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
10457 int TrackVectorPosition;
10509 FinishElement =
false;
10510 int TrackVectorPosition;
10533 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
10544 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
10567 for(
int x = 0; x < 4; x++)
10590 FinishElement =
true;
10598 for(
int x = 0; x < 4; x++)
10610 FinishElement =
true;
10618 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10625 .ELinkPos] ==
Lead))
10641 FinishElement =
true;
10660 FinishElement =
true;
10679 FinishElement =
true;
10694 FinishElement =
true;
10703 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10719 FinishElement =
true;
10725 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10748 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
10749 int VectorCount = 0;
10753 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
10755 for(
int x = 0; x < VectorCount; x++)
10760 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
10764 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
10765 SearchElement.
ELinkPos = NextELinkPos;
10778 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
10780 SearchElement.
XLinkPos = NextXLinkPos;
10806 for(
int x = 0; x < VectorCount; x++)
10816 for(
int x = 0; x < VectorCount; x++)
10828 for(
int x = 0; x < VectorCount; x++)
10840 for(
int x = 0; x < VectorCount; x++)
10849 for(
int x = 0; x < VectorCount; x++)
10858 SearchElement.
XLink = SearchElement.
Link[1];
10877 SearchElement.
XLink = SearchElement.
Link[3];
10890 for(
int x = 0; x < VectorCount; x++)
10902 XLinkPos = NextXLinkPos;
10903 CurrentTrackElement = SearchElement;
10922 throw Exception(
"Error, SearchVector empty");
10929 for(
int x = 0; x < 4; x++)
10974 throw Exception(
"Error in EntryExitNumber 1");
10994 if(PrefDirElement.
XLink == -1)
11002 if(PrefDirElement.
XLink != -1)
11006 throw Exception(
"Error in EntryExitNumber 2");
11042 LeadingPoints =
false;
11070 LeadingPoints =
true;
11086 AnsiString ErrorString;
11087 bool Error =
false;
11094 ErrorString =
"HLoc";
11100 ErrorString =
"VLoc";
11106 ErrorString =
"ELink";
11112 ErrorString =
"ELinkPos";
11118 ErrorString =
"XLink";
11124 ErrorString =
"XLinkPos";
11130 ErrorString =
"Tag";
11136 ErrorString =
"TrackVectorPosition";
11142 ErrorString =
"EXNumber";
11149 ErrorString =
"CheckCount";
11156 ErrorString =
"EntryGraphicPtr";
11162 ErrorString =
"EntryDirectionGraphicPtr";
11171 ErrorString =
"Last XLink not connected to this element";
11178 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
11202 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
11259 AnsiString((
short)BuildingPrefDir));
11262 if(PrefDirSize() == 0)
11267 for(
unsigned int x = 0; x < PrefDirSize(); x++)
11279 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
11291 if(x == (PrefDirSize() - 1))
11300 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
11302 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
11303 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
11304 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
11306 if(PrefDirSize() > 1)
11308 unsigned int LatestPos = PrefDirSize() - 1;
11309 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
11310 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
11311 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
11333 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
11336 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
11340 H = MMIT->first.first;
11341 V = MMIT->first.second;
11344 if(PrefDirPos0 > -1)
11346 if(PrefDirPos1 > -1)
11348 if(PrefDirPos2 > -1)
11350 if(PrefDirPos3 > -1)
11352 if(PrefDirPos3 > -1)
11367 else if(PrefDirPos2 > -1)
11406 else if(PrefDirPos1 > -1)
11427 else if(PrefDirPos0 > -1)
11446 int NumberOfPrefDirElements = 0;
11449 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11451 VecFile >> TempInt;
11454 VecFile >> TempInt;
11455 LoadPrefDirElement.
ELink = TempInt;
11456 VecFile >> TempInt;
11457 LoadPrefDirElement.
ELinkPos = TempInt;
11458 VecFile >> TempInt;
11459 LoadPrefDirElement.
XLink = TempInt;
11460 VecFile >> TempInt;
11461 LoadPrefDirElement.
XLinkPos = TempInt;
11462 VecFile >> TempInt;
11463 LoadPrefDirElement.
EXNumber = TempInt;
11464 VecFile >> TempInt;
11469 if(!(LoadPrefDirElement.
IsARoute))
11495 int NumberOfPrefDirElements = 0;
11498 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11500 VecFile >> TempInt;
11501 VecFile >> TempInt;
11504 VecFile >> TempInt;
11505 LoadPrefDirElement.
ELink = TempInt;
11506 VecFile >> TempInt;
11507 LoadPrefDirElement.
ELinkPos = TempInt;
11508 VecFile >> TempInt;
11509 LoadPrefDirElement.
XLink = TempInt;
11510 VecFile >> TempInt;
11511 LoadPrefDirElement.
XLinkPos = TempInt;
11512 VecFile >> TempInt;
11513 LoadPrefDirElement.
EXNumber = TempInt;
11514 VecFile >> TempInt;
11519 if(!(LoadPrefDirElement.
IsARoute))
11547 int NumberOfPrefDirElements = 0;
11550 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
11555 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11562 VecFile >> TempInt;
11563 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
11568 VecFile >> TempInt;
11569 if((TempInt < -1) || (TempInt > 9))
11574 VecFile >> TempInt;
11575 if((TempInt < -1) || (TempInt > 3))
11580 VecFile >> TempInt;
11581 if((TempInt < -1) || (TempInt > 9))
11586 VecFile >> TempInt;
11587 if((TempInt < -1) || (TempInt > 3))
11592 VecFile >> TempInt;
11593 if((TempInt < -1) || (TempInt > 27))
11598 VecFile >> TempInt;
11606 VecFile >> TempInt;
11607 if((TempInt != 0) && (TempInt != 1))
11612 VecFile >> TempInt;
11613 if((TempInt != 0) && (TempInt != 1))
11618 VecFile >> TempInt;
11619 if((TempInt != 0) && (TempInt != 1))
11642 for(
int y = 0; y < NumberOfPrefDirElements; y++)
11644 VecFile << y <<
'\n';
11645 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
11655 if(y == (NumberOfPrefDirElements - 1))
11657 VecFile <<
"************" <<
'\0' <<
'\n';
11661 VecFile <<
"******" <<
'\0' <<
'\n';
11675 for(
int y = 0; y < NumberOfSearchElements; y++)
11677 VecFile << y <<
'\n';
11678 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
11688 if(y == (NumberOfSearchElements - 1))
11690 VecFile <<
"************" <<
'\0' <<
'\n';
11694 VecFile <<
"******" <<
'\0' <<
'\n';
11799 bool AlreadyPresent, FoundFlag;
11800 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
11802 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
11806 AlreadyPresent =
false;
11810 AlreadyPresent =
true;
11812 AlreadyPresent =
true;
11814 AlreadyPresent =
true;
11816 AlreadyPresent =
true;
11818 if(!AlreadyPresent)
11863 for(
unsigned int z = 0; z < 4; z++)
11871 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
11885 bool DiscrepancyFound =
false;
11895 DiscrepancyFound =
true;
11898 DiscrepancyFound =
true;
11903 DiscrepancyFound =
true;
11908 DiscrepancyFound =
true;
11913 DiscrepancyFound =
true;
11918 DiscrepancyFound =
true;
11920 if(DiscrepancyFound)
11922 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
11937 bool DiscrepancyFound =
false;
11947 DiscrepancyFound =
true;
11950 DiscrepancyFound =
true;
11955 DiscrepancyFound =
true;
11960 DiscrepancyFound =
true;
11965 DiscrepancyFound =
true;
11970 DiscrepancyFound =
true;
11973 return !DiscrepancyFound;
11985 bool FoundFlag =
false;
11986 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
11994 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
11995 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
11997 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
11999 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
12000 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
12001 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
12006 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
12007 +
" Caller=" + (AnsiString)Caller);
12033 PrefDirMapKeyPair.first = HLoc;
12034 PrefDirMapKeyPair.second = VLoc;
12035 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12038 if(ItPair.first == ItPair.second)
12046 PrefDirPos0 = ItPair.first->second;
12048 if(ItPair.first == ItPair.second)
12053 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
12054 PrefDirPos1 = ItPair.first->second;
12056 if(ItPair.first == ItPair.second)
12061 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
12062 PrefDirPos2 = ItPair.first->second;
12064 if(ItPair.first == ItPair.second)
12069 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
12070 PrefDirPos3 = ItPair.first->second;
12084 THVPair PrefDir4MultiMapKeyPair;
12087 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
12088 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
12089 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
12112 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
12131 AnsiString(ErasedElementNumber));
12136 if(MapPtr->second > ErasedElementNumber)
12156 throw Exception(
"PrefDirVectorPosition out of range");
12159 THVPair PrefDir4MultiMapKeyPair;
12161 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
12162 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
12163 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12166 if(ItPair.first == ItPair.second)
12169 return ItPair.first;
12173 if(ItPair.first->second == PrefDirVectorPosition)
12177 return ItPair.first;
12180 if(ItPair.first == ItPair.second)
12183 return ItPair.first;
12185 if(ItPair.first->second == PrefDirVectorPosition)
12189 return ItPair.first;
12192 if(ItPair.first == ItPair.second)
12195 return ItPair.first;
12197 if(ItPair.first->second == PrefDirVectorPosition)
12201 return ItPair.first;
12204 if(ItPair.first == ItPair.second)
12207 return ItPair.first;
12209 if(ItPair.first->second == PrefDirVectorPosition)
12213 return ItPair.first;
12217 return ItPair.first;
12230 THVPair PrefDir4MultiMapKeyPair;
12232 PrefDir4MultiMapKeyPair.first = HLoc;
12233 PrefDir4MultiMapKeyPair.second = VLoc;
12234 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12237 if(ItPair.first == ItPair.second)
12245 return ItPair.first->second;
12254 bool ErasedFlag =
false;
12256 if(ErasedTrackVectorPosition > -1)
12265 ErasedFlag =
false;
12267 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
12272 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
12277 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
12282 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
12287 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
12295 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
12299 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
12303 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
12307 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
12311 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
12326 OverallDistance = 0;
12327 OverallSpeedLimit = 0;
12328 LeadingPointsAtLastElement =
false;
12337 LeadingPointsAtLastElement =
true;
12346 OverallDistance += PrefDirElement.
Length23;
12347 if(OverallSpeedLimit != -1)
12357 OverallSpeedLimit = -1;
12364 OverallDistance += PrefDirElement.
Length01;
12365 if(OverallSpeedLimit != -1)
12375 OverallSpeedLimit = -1;
12395 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12398 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12402 HLoc = MMIT->first.first;
12403 VLoc = MMIT->first.second;
12408 if(PrefDirPos0 > -1)
12410 if(PrefDirPos1 > -1)
12412 if(PrefDirPos2 > -1)
12414 if(PrefDirPos3 > -1)
12416 if(PrefDirPos3 > -1)
12418 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12420 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12422 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12424 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
12431 else if(PrefDirPos2 > -1)
12435 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12437 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12439 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
12447 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12449 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12451 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
12459 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12461 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12463 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12470 else if(PrefDirPos1 > -1)
12474 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12476 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12483 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12485 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
12491 else if(PrefDirPos0 > -1)
12493 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12510 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12513 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12534 if(PrefDirPos0 > -1)
12536 if(PrefDirPos1 > -1)
12538 if(PrefDirPos2 > -1)
12540 if(PrefDirPos3 > -1)
12543 if(PrefDirPos3 > -1)
12548 else if(PrefDirPos2 > -1)
12550 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
12561 else if(PrefDirPos1 > -1)
12563 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
12574 else if(PrefDirPos0 > -1)
12576 if(PrefDirElement0.
XLinkPos == EntryPos)
12613 ElementIn.
VLoc +
"," + XLink);
12615 bool TrackFoundFlag;
12618 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
12631 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
12641 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
12656 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
12666 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
12681 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
12691 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
12706 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
12716 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
12739 bool FoundFlag, ContFlag, FoundElements =
false;
12740 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12745 LastIteratorValue++;
12766 if(PDVIt->XLinkPos == 0)
12771 StartElement = *PDVIt;
12780 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
12782 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
12783 if(PrefDirPos0 == -1)
12787 bool NextElementFoundFlag =
false;
12791 NextElementFoundFlag =
true;
12793 if(PrefDirPos1 > -1)
12798 NextElementFoundFlag =
true;
12801 if(PrefDirPos2 > -1)
12806 NextElementFoundFlag =
true;
12809 if(PrefDirPos3 > -1)
12814 NextElementFoundFlag =
true;
12817 if(!NextElementFoundFlag)
12847 EndElement = NextElement;
12851 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
12853 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
12854 if(PrefDirPos0 == -1)
12864 if(PrefDirPos1 > -1)
12872 if(PrefDirPos2 > -1)
12880 if(PrefDirPos3 > -1)
12909 FoundElements =
true;
12973 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
12975 int TrackVectorPosition;
12984 if(ConsecSignalsRoute)
13027 int LockedVectorNumber;
13051 bool InPrefDirFlag =
false;
13054 int PrefDirPos0 = -1;
13055 int PrefDirPos1 = -1;
13056 int PrefDirPos2 = -1;
13057 int PrefDirPos3 = -1;
13061 int PrefDirVecPos[4] =
13062 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
13064 for(
int x = 0; x < 4; x++)
13066 int b = PrefDirVecPos[x];
13069 if(ConsecSignalsRoute)
13078 InPrefDirFlag =
true;
13096 InPrefDirFlag =
true;
13102 InPrefDirFlag =
true;
13115 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
13124 if(DummyPair.first > -1)
13126 throw Exception(
"Selection in two routes - should never happen!");
13129 if(RoutePair.first > -1)
13159 if(ConsecSignalsRoute)
13209 IDInt &ReqPosRouteID,
bool &PointsChanged)
13249 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
13288 if(ConsecSignalsRoute)
13317 bool InPrefDirFlag =
false;
13320 int PrefDirPos0 = -1;
13321 int PrefDirPos1 = -1;
13322 int PrefDirPos2 = -1;
13323 int PrefDirPos3 = -1;
13326 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
13327 int PrefDirVecPos[4] =
13328 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
13330 for(
int x = 0; x < 4; x++)
13332 int b = PrefDirVecPos[x];
13335 InPrefDirFlag =
true;
13345 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
13355 if(RoutePair.first > -1)
13357 if(RoutePair.second != 0)
13374 EndElement1 = RouteElement;
13375 EndElement2 = BlankElement;
13480 PointsChanged =
true;
13505 PointsChanged =
true;
13526 PointsChanged =
true;
13554 PointsChanged =
true;
13568 PointsChanged =
true;
13584 PointsChanged =
true;
13595 PointsChanged =
true;
13611 PointsChanged =
true;
13663 TOnePrefDir *EveryPrefDir,
bool ConsecSignalsRoute,
int EndPosition,
bool AutoSigsFlag)
13716 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
13717 AnsiString((
short)AutoSigsFlag));
13718 int VectorCount = 0;
13722 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
13726 for(
int x = 0; x < VectorCount; x++)
13733 bool FirstPass =
true;
13743 for(
int x = 0; x < VectorCount; x++)
13750 for(
int x = 0; x < VectorCount; x++)
13755 if(!FirstPass && (ConsecSignalsRoute) && (PrefDirElement.
Config[PrefDirElement.
XLinkPos] ==
Signal))
13760 for(
int x = 0; x < VectorCount; x++)
13766 int NextPosition = PrefDirElement.
Conn[XLinkPos];
13770 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
13771 SearchElement.
ELinkPos = NextELinkPos;
13772 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
13785 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
13787 SearchElement.
XLinkPos = NextXLinkPos;
13799 for(
int x = 0; x < VectorCount; x++)
13811 if(RoutePair.first > -1)
13820 for(
int x = 0; x < VectorCount; x++)
13827 if(SecondPair.first > -1)
13836 for(
int x = 0; x < VectorCount; x++)
13849 for(
int x = 0; x < VectorCount; x++)
13858 for(
int x = 0; x < VectorCount; x++)
13865 for(
int x = 0; x < VectorCount; x++)
13873 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
13877 for(
int x = 0; x < VectorCount; x++)
13885 bool InPrefDirFlag =
false;
13886 PrefDirElement1 = BlankElement;
13887 PrefDirElement2 = BlankElement;
13890 int PrefDirPos0 = -1;
13891 int PrefDirPos1 = -1;
13892 int PrefDirPos2 = -1;
13893 int PrefDirPos3 = -1;
13896 int PrefDirVecPos[4] =
13897 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
13898 for(
int x = 0; x < 4; x++)
13900 int b = PrefDirVecPos[x];
13903 InPrefDirFlag =
true;
13912 for(
int x = 0; x < VectorCount; x++)
13923 for(
int x = 0; x < VectorCount; x++)
13936 for(
int x = 0; x < VectorCount; x++)
13945 if(ConsecSignalsRoute)
13956 for(
int x = 0; x < VectorCount; x++)
13970 for(
int x = 0; x < VectorCount; x++)
13978 for(
int x = 0; x < VectorCount; x++)
13987 int SearchPos1 = SearchElement.
Attribute + 1;
13989 if(SearchPos1 == 2)
13991 if(SearchPos1 == 1)
13995 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
13996 SearchElement.
XLinkPos = SearchPos1;
13997 InPrefDirFlag =
false;
13998 if(SearchElement.
XLink == PrefDirElement1.
XLink)
14000 SearchElement = PrefDirElement1;
14001 InPrefDirFlag =
true;
14003 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
14005 SearchElement = PrefDirElement2;
14006 InPrefDirFlag =
true;
14012 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
14016 for(
int x = 0; x < VectorCount; x++)
14026 if(ConsecSignalsRoute)
14044 for(
int x = 0; x < VectorCount; x++)
14060 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
14061 SearchElement.
XLinkPos = SearchPos2;
14062 if(SearchElement.
XLink == PrefDirElement1.
XLink)
14064 SearchElement = PrefDirElement1;
14066 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
14068 SearchElement = PrefDirElement2;
14072 for(
int x = 0; x < VectorCount; x++)
14078 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
14082 for(
int x = 0; x < VectorCount; x++)
14093 if(ConsecSignalsRoute)
14111 for(
int x = 0; x < VectorCount; x++)
14121 for(
int x = 0; x < VectorCount; x++)
14128 SearchElement = PrefDirElement1;
14133 if(ConsecSignalsRoute)
14140 XLinkPos = SearchElement.
XLinkPos;
14141 PrefDirElement = SearchElement;
14198 unsigned int TruncatePrefDirPosition = 0;
14272 throw Exception(
"Error - failed to validate extended route for preferred route");
14328 throw Exception(
"Error - failed to validate single route for preferred route");
14377 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
14379 int TrackVectorPosition;
14415 int LockedVectorNumber;
14446 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
14447 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
14450 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
14456 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
14457 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
14460 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
14474 if(RoutePair.first > -1)
14658 EndElement1.
ELink = EndElement1.
Link[0];
14659 EndElement1.
XLink = EndElement1.
Link[1];
14662 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
14667 EndElement2.
ELink = EndElement2.
Link[1];
14668 EndElement2.
XLink = EndElement2.
Link[0];
14671 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
14717 if(RoutePair.first > -1)
14719 if(RoutePair.second != 0)
14738 EndElement2 = BlankElement;
14817 PointsChanged =
true;
14841 PointsChanged =
true;
14861 PointsChanged =
true;
14885 PointsChanged =
true;
14899 PointsChanged =
true;
14937 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
14938 int VectorCount = 0;
14941 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
14942 (CurrentTrackElement.
Link[XLinkPos] == 9))
14946 for(
int x = 0; x < VectorCount; x++)
14957 for(
int x = 0; x < VectorCount; x++)
14962 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
14964 for(
int x = 0; x < VectorCount; x++)
14969 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
14973 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
14974 SearchElement.
ELinkPos = NextELinkPos;
14987 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
14989 SearchElement.
XLinkPos = NextXLinkPos;
15002 for(
int x = 0; x < VectorCount; x++)
15014 if(RoutePair.first > -1)
15023 for(
int x = 0; x < VectorCount; x++)
15030 if(SecondPair.first > -1)
15039 for(
int x = 0; x < VectorCount; x++)
15052 for(
int x = 0; x < VectorCount; x++)
15061 for(
int x = 0; x < VectorCount; x++)
15068 for(
int x = 0; x < VectorCount; x++)
15076 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15080 for(
int x = 0; x < VectorCount; x++)
15092 for(
int x = 0; x < VectorCount; x++)
15119 for(
int x = 0; x < VectorCount; x++)
15128 for(
int x = 0; x < VectorCount; x++)
15138 int SearchPos1 = SearchElement.
Attribute + 1;
15140 if(SearchPos1 == 2)
15142 if(SearchPos1 == 1)
15147 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
15148 SearchElement.
XLinkPos = SearchPos1;
15150 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15154 for(
int x = 0; x < VectorCount; x++)
15177 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
15178 SearchElement.
XLinkPos = SearchPos2;
15180 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15184 for(
int x = 0; x < VectorCount; x++)
15201 for(
int x = 0; x < VectorCount; x++)
15213 CurrentTrackElement = SearchElement;
15214 XLinkPos = SearchElement.
XLinkPos;
15236 throw Exception(
"Error, SearchVector empty");
15248 for(
int x = 0; x < 4; x++)
15282 throw Exception(
"Error in EntryExitNumber 3");
15338 unsigned int TruncatePrefDirPosition = 0;
15399 throw Exception(
"Failed to validate extended route for nonpreferred route");
15445 throw Exception(
"Failed to validate single route for nonpreferred route");
15465 if(!PrefDirVector.empty())
15469 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
15474 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
15509 if(!PrefDirVector.empty())
15512 TPrefDirElement LastElement = GetFixedPrefDirElementAt(185, PrefDirSize() - 1);
15514 int ForwardLinkedRouteNumber, Attribute = 0;
15521 if(ForwardLinkedRouteNumber > -1)
15523 int NextForwardLinkedRouteNumber = -1;
15527 ForwardLinkedRouteNumber = NextForwardLinkedRouteNumber;
15537 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
15556 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
15564 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
15595 NextForwardLinkedRouteNumber = -1;
15596 for(
unsigned int x = 0; x < PrefDirSize(); x++)
15598 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
15599 if(PrefDirVector.at(x).TrackType ==
Bridge)
15601 if(PrefDirVector.at(x).XLinkPos < 2)
15602 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos01;
15604 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos23;
15611 if(PrefDirVector.at(x).TrackType ==
Buffers)
15623 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
15632 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
15634 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute + 1;
15640 if(x == PrefDirSize() - 1)
15682 AnsiString(PrefDirVectorStartPosition));
15687 bool SkipContinuationAndBufferAttributeChange =
false;
15689 if(!PrefDirVector.empty())
15691 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
15694 if(PrefDirPtr->TrackType ==
Bridge)
15696 if(PrefDirPtr->XLinkPos < 2)
15703 SkipContinuationAndBufferAttributeChange =
true;
15718 SkipContinuationAndBufferAttributeChange =
true;
15726 SkipContinuationAndBufferAttributeChange =
true;
15728 if(!SkipContinuationAndBufferAttributeChange)
15730 if(PrefDirVector.back().TrackType ==
Buffers)
15736 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
15739 if(PrefDirPtr->TrackType ==
Bridge)
15741 if(PrefDirPtr->XLinkPos < 2)
15753 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
15762 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
15764 if((!
AllRoutes->
RouteTruncateFlag) || (PrefDirPtr != (PrefDirVector.begin() + PrefDirVectorStartPosition)) || PrefDirPtr->AutoSignals ||
15765 PrefDirPtr->ConsecSignals)
15806 "," + AnsiString((
short)ConsecSignalsRoute));
15807 bool ElementInRoute =
false;
15808 bool TrainOccupyingRoute =
false;
15814 ElementInRoute =
true;
15818 if(!ElementInRoute)
15842 TrainOccupyingRoute =
true;
15910 if(LRVIT->RouteNumber == RouteNumber)
15925 int button = Application->MessageBox(L
"Train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
15926 L
"Warning!", MB_YESNO | MB_ICONWARNING);
15938 bool ExistingLockedRouteModified =
false;
15951 if(LRVIT->RouteNumber == RouteNumber)
15955 ExistingLockedRouteModified =
true;
15959 if(!ExistingLockedRouteModified)
16047 AnsiString((
short)ConsecSignalsRoute));
16057 ConsecSignalsRoute);
16072 AnsiString((
short)ConsecSignalsRoute));
16082 RouteFlashElement.
HLoc = H;
16083 RouteFlashElement.
VLoc = V;
16099 int H = PrefDirPtr->HLoc;
16100 int V = PrefDirPtr->VLoc;
16162 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
16166 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
16169 OverlayPlotted =
false;
16179 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
16181 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
16184 return AllRoutesVector.at(At);
16193 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
16195 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
16198 return AllRoutesVector.at(At);
16209 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16211 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
16221 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16223 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
16241 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignalsRoute));
16242 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16245 RouteTruncateFlag =
true;
16247 GetModifiableRouteAt(7, a).GetRouteTruncateElement(0, HLoc, VLoc, ConsecSignalsRoute, ReturnFlag);
16248 RouteTruncateFlag =
false;
16275 AnsiString(LinkPos));
16276 if(TrackVectorPosition == -1)
16281 THVPair Route2MultiMapKeyPair;
16285 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16288 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16298 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16300 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16303 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
16304 Route2MultiMapIterator->second.second);
16305 EntryLinkPos = PrefDirElement1.
ELinkPos;
16306 ExitLinkPos = PrefDirElement1.
XLinkPos;
16307 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16308 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16320 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16332 Graphics::TBitmap* &EntryDirectionGraphicPtr)
16342 AnsiString(LinkPos));
16345 if(TrackVectorPosition == -1)
16350 THVPair Route2MultiMapKeyPair;
16354 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16357 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16362 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16364 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16366 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
16367 Route2MultiMapIterator->second.second);
16368 EntryLinkPos = PrefDirElement1.
ELinkPos;
16369 ExitLinkPos = PrefDirElement1.
XLinkPos;
16370 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16371 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16375 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
16376 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
16383 return AutoSigsRoute;
16388 return NotAutoSigsRoute;
16394 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
16395 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
16402 return AutoSigsRoute;
16407 return NotAutoSigsRoute;
16411 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16413 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16414 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16416 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
16417 EntryLinkPos = PrefDirElement2.
ELinkPos;
16418 ExitLinkPos = PrefDirElement2.
XLinkPos;
16419 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
16420 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
16424 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
16431 return AutoSigsRoute;
16436 return NotAutoSigsRoute;
16442 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
16449 return AutoSigsRoute;
16454 return NotAutoSigsRoute;
16459 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
16460 EntryLinkPos = PrefDirElement3.
ELinkPos;
16461 ExitLinkPos = PrefDirElement3.
XLinkPos;
16462 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
16463 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
16467 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
16474 return AutoSigsRoute;
16479 return NotAutoSigsRoute;
16485 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
16492 return AutoSigsRoute;
16497 return NotAutoSigsRoute;
16513 AnsiString(LinkPos));
16514 if(TrackVectorPosition == -1)
16520 THVPair Route2MultiMapKeyPair;
16524 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16527 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16533 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16535 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16537 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
16538 Route2MultiMapIterator->second.second);
16539 EntryLinkPos = PrefDirElement1.
ELinkPos;
16540 ExitLinkPos = PrefDirElement1.
XLinkPos;
16541 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16542 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16545 RouteNumber = Route2MultiMapIterator->second.first;
16549 return AutoSigsRoute;
16554 return NotAutoSigsRoute;
16559 RouteNumber = Route2MultiMapIterator->second.first;
16563 return AutoSigsRoute;
16568 return NotAutoSigsRoute;
16572 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16574 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16575 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16577 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
16578 EntryLinkPos = PrefDirElement2.
ELinkPos;
16579 ExitLinkPos = PrefDirElement2.
XLinkPos;
16580 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
16581 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
16584 RouteNumber = ItPair.first->second.first;
16588 return AutoSigsRoute;
16593 return NotAutoSigsRoute;
16598 RouteNumber = ItPair.first->second.first;
16602 return AutoSigsRoute;
16607 return NotAutoSigsRoute;
16612 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
16613 EntryLinkPos = PrefDirElement3.
ELinkPos;
16614 ExitLinkPos = PrefDirElement3.
XLinkPos;
16615 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
16616 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
16619 RouteNumber = ItPair.second->second.first;
16623 return AutoSigsRoute;
16628 return NotAutoSigsRoute;
16633 RouteNumber = ItPair.second->second.first;
16637 return AutoSigsRoute;
16642 return NotAutoSigsRoute;
16664 EmptyRoute.
RouteID = NextRouteID;
16667 AllRoutesVector.push_back(EmptyRoute);
16668 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
16693 AllRoutesVector.push_back(EmptyRoute);
16694 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
16717 THVPair Route2MultiMapKeyPair;
16726 LockedRouteTruncateTrackVectorPosition = 0;
16727 LockedRouteLastTrackVectorPosition = 0;
16728 LockedRouteLastXLinkPos = 0;
16729 LockedRouteLockStartTime = TDateTime(0);
16730 if(!LockedRouteVector.empty())
16734 if(LRVIT->RouteNumber == RouteNumber)
16736 LockedRouteTruncateTrackVectorPosition = LRVIT->TruncateTrackVectorPosition;
16737 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
16738 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
16739 LockedRouteLockStartTime = LRVIT->LockStartTime;
16740 LockedRouteFoundDuringRouteBuilding =
true;
16741 LockedRouteVector.erase(LRVIT);
16767 AnsiString(VLoc) +
"," + AnsiString(ELink));
16770 ReturnPair.first = -1;
16771 ReturnPair.second = 0;
16772 THVPair Route2MultiMapKeyPair;
16774 Route2MultiMapKeyPair.first = HLoc;
16775 Route2MultiMapKeyPair.second = VLoc;
16778 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
16779 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16781 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16782 Route2MultiMapIterator = ItPair.first;
16784 if(ItPair.first == ItPair.second)
16786 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
16789 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
16791 ReturnPair.first = ItPair.first->second.first;
16792 ReturnPair.second = ItPair.first->second.second;
16793 Route2MultiMapIterator = ItPair.first;
16798 if(ItPair.first == ItPair.second)
16800 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
16802 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
16804 ReturnPair.first = ItPair.first->second.first;
16805 ReturnPair.second = ItPair.first->second.second;
16806 Route2MultiMapIterator = ItPair.first;
16826 AnsiString(VLoc) +
"," + AnsiString(ELink));
16827 THVPair Route2MultiMapKeyPair;
16829 Route2MultiMapKeyPair.first = HLoc;
16830 Route2MultiMapKeyPair.second = VLoc;
16831 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16833 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16835 if(ItPair.first == ItPair.second)
16842 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
16844 RouteNumber = ItPair.first->second.first;
16851 if(ItPair.first == ItPair.second)
16858 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
16860 RouteNumber = ItPair.first->second.first;
16881 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
16882 THVPair Route2MultiMapKeyPair;
16884 Route2MultiMapKeyPair.first = HLoc;
16885 Route2MultiMapKeyPair.second = VLoc;
16888 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
16891 RouteElementPair.first = RouteNumber;
16892 RouteElementPair.second = RouteElementNumber;
16893 Route2MultiMapEntry.second = RouteElementPair;
16895 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
16898 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
16899 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
16902 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
16903 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
16905 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
16907 Route2MultiMap.insert(Route2MultiMapEntry);
16912 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
16916 Route2MultiMap.insert(Route2MultiMapEntry);
16933 TempPair.first = -1;
16934 TempPair.second = 0;
16935 SecondPair = TempPair;
16937 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
16938 THVPair Route2MultiMapKeyPair;
16940 Route2MultiMapKeyPair.first = HLoc;
16941 Route2MultiMapKeyPair.second = VLoc;
16942 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16947 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16949 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16951 return Route2MultiMapIterator->second;
16953 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16955 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16956 TempPair = ItRange.first->second;
16957 SecondPair = (--ItRange.second)->second;
16980 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
16981 if(RouteElementPair.first == -1)
16984 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
16985 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
16987 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
16990 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
16991 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
16992 (AnsiString)Caller);
16994 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
16997 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
16998 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
16999 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
17000 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
17004 unsigned int SizeVal = 0;
17007 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
17009 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
17011 if(SizeVal != Route2MultiMap.size())
17013 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
17014 (AnsiString)Caller);
17030 if(!Route2MultiMap.empty())
17032 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
17034 if(Route2MultiMapIterator->second.first > RouteNumber)
17035 Route2MultiMapIterator->second.first--;
17051 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
17052 if(!Route2MultiMap.empty())
17054 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
17056 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
17057 Route2MultiMapIterator->second.second--;
17075 AnsiString(ELink));
17079 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
17080 if(RequiredRoutePair.first == -1)
17082 throw Exception(
"Failed to find route element in RemoveRouteElement");
17084 Route2MultiMap.erase(Route2MultiMapIterator);
17085 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
17088 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
17110 GetModifiableRouteAt(8, RequiredRoutePair.first).EraseRouteElementAt(&(GetModifiableRouteAt(9, RequiredRoutePair.first).GetModifiablePrefDirElementAt(1,
17111 RequiredRoutePair.second)));
17122 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
17131 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
17133 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
17134 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
17135 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
17147 if(!LockedRouteVector.empty())
17151 if(LRVIT->RouteNumber > RequiredRoutePair.first)
17153 LRVIT->RouteNumber--;
17164 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
17165 AutoSigVectorIT->RouteNumber--;
17169 CheckMapAndRoutes(7);
17183 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
17184 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
17185 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
17201 "," + AnsiString(XLinkPos));
17205 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
17206 if(RouteElementPair.first == -1)
17208 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
17210 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
17212 RequiredPair = RouteElementPair;
17213 if(RouteElement.
XLinkPos != XLinkPos)
17215 if(SecondPair.first != -1)
17217 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
17218 RequiredPair = SecondPair;
17219 if(RouteElement.
XLinkPos != XLinkPos)
17221 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
17226 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
17231 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
17251 AnsiString(AccessNumber));
17253 int Attribute = AccessNumber + 1;
17255 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
17259 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
17263 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
17266 x).XLinkPos] !=
End)
17268 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
17271 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
17313 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
17314 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
17315 int RearwardLinkedRouteNumber;
17339 int TrainID, TrainPosition, BehindTrainPosition;
17340 bool FoundTrain =
false, BehindTrain =
false;
17341 for(
int x = RouteStartPosition; x >= 0; x--)
17343 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
17362 if(FoundTrain && (TrainPosition > 1))
17364 for(
int x = TrainPosition; x >= 0; x--)
17369 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
17383 BehindTrain =
true;
17384 BehindTrainPosition = x;
17391 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
17408 AnsiString(RouteTruncatePosition));
17409 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber, StartPosition = RouteTruncatePosition;
17410 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
17413 bool ExamineRoute =
true;
17415 while(ExamineRoute)
17417 for(
int x = StartPosition; x >= 0; x--)
17454 if(SignalCount >= 3)
17473 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
17474 ExamineRoute =
true;
17475 StartPosition = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
17506 ExamineRoute =
false;
17521 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
17524 PrefDirElement = InternalPrefDirElement;
17525 if(LockedRouteVector.empty())
17532 bool InLockedRoute =
false;
17536 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
17539 InLockedRoute =
true;
17549 int RouteNumber, VectorCount = 0;
17554 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
17555 if(RouteType == NoRoute)
17559 GetFixedRouteAt(140, RouteNumber).
PrefDirSize() - 1).XLinkPos != LRVIT->LastXLinkPos))
17562 (
"Error, last element in locked route doesn't correspond with last element in associated route in IsElementInLockedRouteGetPrefDirElement");
17564 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
17566 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
17567 if(InternalPrefDirElement.
TrackVectorPosition != (
int)LRVIT->TruncateTrackVectorPosition)
17571 PrefDirElement = InternalPrefDirElement;
17572 LockedVectorNumber = VectorCount;
17577 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->TruncateTrackVectorPosition)
17581 PrefDirElement = InternalPrefDirElement;
17582 LockedVectorNumber = VectorCount;
17601 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17603 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
17609 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
17619 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17621 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
17636 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17638 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
17641 return GetFixedRouteAt(159, x);
17644 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
17652 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17654 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
17657 return GetModifiableRouteAt(15, x);
17660 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
17670 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17672 TOneRoute OneRoute = GetFixedRouteAt(165, x);
17684 int NumberOfRoutes;
17688 for(
int x = 0; x < NumberOfRoutes; x++)
17695 StoreOneRouteAfterSessionLoad(0, &OneRoute);
17713 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
17720 if((NextID < 0) || (NextID > 1000000))
17725 for(
int x = 0; x < NumberOfRoutes; x++)
17749 AnsiString(StartPosition));
17750 if(EndPosition == StartPosition)
17756 int TVPos = EndPosition;
17757 int LkPos = EndXLinkPos;
17759 while(TrackIsInARoute(15, TVPos, LkPos))
17786 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
17795 if((NewLkPos == 0) || (NewLkPos == 2))
17807 if(TVPos == StartPosition)
17839 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
17844 if(FirstPair.first > -1)
17847 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17852 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17858 if(SecondPair.first > -1)
17861 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17866 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17873 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
17881 if(FirstPair.first > -1)
17884 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17889 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17895 if(SecondPair.first > -1)
17898 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17903 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17910 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
17918 if(FirstPair.first > -1)
17921 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17926 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17932 if(SecondPair.first > -1)
17935 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17940 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17947 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
17955 if(FirstPair.first > -1)
17958 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17963 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17969 if(SecondPair.first > -1)
17972 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17977 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17984 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
18009 "," + AnsiString(DiagonalLinkNumber));
18014 if(FirstPair.first > -1)
18017 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
18022 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
18028 if(SecondPair.first > -1)
18031 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
18036 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
18044 if(FirstPair.first > -1)
18047 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
18052 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
18058 if(SecondPair.first > -1)
18061 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
18066 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
18074 if(FirstPair.first > -1)
18077 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
18082 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
18088 if(SecondPair.first > -1)
18091 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
18096 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
18104 if(FirstPair.first > -1)
18107 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
18112 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
18118 if(SecondPair.first > -1)
18121 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
18126 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))